package com.ihg.hiex.entity.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.ihg.hiex.entity.data.conference.ConferenceRoom;

/**
 * 
 * @author downpour
 * 
 */
@Entity
@Table(name = "assessor_user")
public class Assessor {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 所属账户 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Account account;
    
    /** Zoom会议室 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    private ConferenceRoom zoomRoom;
    
    /** BizConf会议室 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    private ConferenceRoom bizconfRoom;
    
    private String name;
    
    private String email;
    
    /** 座机 */
    private String telephone;
    
    /** 用于zoom的手机号码，必须输入 */
    private String mobile;
    
    private String hotelName;
    
    private String subregion;
    
    private String title;
    
    /** 当前测评sessionId */
    private Long currentSessionId;
    
    /** 当前认证 assessorCertificateRecordId */
    private Long currentCertificateRecordId;
    
    private Date createTime;
    
    private Date lastModifyTime;
    
    /** 最后certificate 时间 */
    private Date certificateTime;
    
    /** 是否首次登陆系统 */
    @Column(name = "is_first_land")
    private boolean firstLand; 

    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public Assessor() {
    }
    
    /**
     * @param name
     * @param email
     * @param telephone
     * @param hotelName
     * @param subregion
     * @param title
     */
    public Assessor(String name, String email, String telephone, String hotelName, String subregion, String title) {
        this.name = name;
        this.email = email.toLowerCase();
        this.telephone = telephone;
        this.hotelName = hotelName;
        this.subregion = subregion;
        this.title = title;
    }
    
    /**
     * 
     * @param assessor
     * @return
     */
    public Assessor edit(Assessor assessor) {
        this.name = assessor.getName();
        this.email = assessor.getEmail().toLowerCase();
        this.telephone = assessor.getTelephone();
        this.hotelName = assessor.getHotelName();
        this.subregion = assessor.getSubregion();
        this.title = assessor.getTitle();
        this.lastModifyTime = new Date();
        return this;
    }

    /**
     * 
     * @param account
     * @return
     */
    public Assessor initialize(Account account) {
        this.email = this.email.toLowerCase();
        this.createTime = new Date();
        this.lastModifyTime = new Date();
        this.account = account;
        this.firstLand = true;
        return this;
    }
    
    /**
     * 
     * @param currentCertificateRecordId
     * @return
     */
    public Assessor editCurrentCertificateRecordId(Long currentCertificateRecordId) {
        this.currentCertificateRecordId = currentCertificateRecordId;
        return this;
    }
    
    /**
     * @return
     */
    public boolean hasZoomRoom() {
        return this.zoomRoom != null;
    }
    
    /**
     * @return
     */
    public boolean hasBizconfRoom() {
        return this.bizconfRoom != null;
    }
    
    /**
     * 
     * @param zoomRoom
     * @return
     */
    public Assessor editZoomRoom(ConferenceRoom zoomRoom) {
        this.zoomRoom = zoomRoom;
        return this;
    }
    
    /**
     * @param bizconfRoom
     * @return
     */
    public Assessor editBizconfRoom(ConferenceRoom bizconfRoom) {
        this.bizconfRoom = bizconfRoom;
        return this;
    }

    /**
     * delete.
     * 
     * @return
     */
    public Assessor disable() {
        this.disabled = true;
        this.lastModifyTime = new Date();
        return this;
    }

    /**
     * 
     * @return
     */
    public Assessor edit() {
    	this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * @return
     */
    public Assessor land() {
        this.firstLand = false;
        return this;
    }
    
    /**
     * 
     * @param currentSessionId
     * @return
     */
    public Assessor editSessionId(Long currentSessionId) {
        this.currentSessionId = currentSessionId;
        return this;
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public String getIdString() {
        return id.toString();
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the account
     */
    public Account getAccount() {
        return account;
    }

    /**
     * @return the zoomRoom
     */
    public ConferenceRoom getZoomRoom() {
        return zoomRoom;
    }

    /**
     * @return the bizconfRoom
     */
    public ConferenceRoom getBizconfRoom() {
        return bizconfRoom;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the telephone
     */
    public String getTelephone() {
        return telephone;
    }

    /**
     * @return the mobile
     */
    public String getMobile() {
        return mobile;
    }

    /**
     * @return the hotelName
     */
    public String getHotelName() {
        return hotelName;
    }

    /**
     * @return the subregion
     */
    public String getSubregion() {
        return subregion;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @return the currentSessionId
     */
    public Long getCurrentSessionId() {
        return currentSessionId;
    }

    /**
     * @return the currentCertificateRecordId
     */
    public Long getCurrentCertificateRecordId() {
        return currentCertificateRecordId;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the certificateTime
     */
    public Date getCertificateTime() {
        return certificateTime;
    }

    /**
     * @return the firstLand
     */
    public boolean isFirstLand() {
        return firstLand;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param account the account to set
     */
    public void setAccount(Account account) {
        this.account = account;
    }

    /**
     * @param zoomRoom the zoomRoom to set
     */
    public void setZoomRoom(ConferenceRoom zoomRoom) {
        this.zoomRoom = zoomRoom;
    }

    /**
     * @param bizconfRoom the bizconfRoom to set
     */
    public void setBizconfRoom(ConferenceRoom bizconfRoom) {
        this.bizconfRoom = bizconfRoom;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param telephone the telephone to set
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    /**
     * @param mobile the mobile to set
     */
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    /**
     * @param hotelName the hotelName to set
     */
    public void setHotelName(String hotelName) {
        this.hotelName = hotelName;
    }

    /**
     * @param subregion the subregion to set
     */
    public void setSubregion(String subregion) {
        this.subregion = subregion;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @param currentSessionId the currentSessionId to set
     */
    public void setCurrentSessionId(Long currentSessionId) {
        this.currentSessionId = currentSessionId;
    }

    /**
     * @param currentCertificateRecordId the currentCertificateRecordId to set
     */
    public void setCurrentCertificateRecordId(Long currentCertificateRecordId) {
        this.currentCertificateRecordId = currentCertificateRecordId;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param certificateTime the certificateTime to set
     */
    public void setCertificateTime(Date certificateTime) {
        this.certificateTime = certificateTime;
    }

    /**
     * @param firstLand the firstLand to set
     */
    public void setFirstLand(boolean firstLand) {
        this.firstLand = firstLand;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
    
}